<!--
 * @Author: ssj
 * @Date: 2021-10-15 17:55:21
 * @LastEditors: zss
 * @LastEditTime: 2024-10-22 11:31:00
 * @Description: 
-->
<template>
  <div class="print-panel">
    <!-- item['module_name'] item['title'] -->
    <RadioGroup v-model="selectedTempIdx" vertical @on-change="onChange">
      <Radio :label="idx" v-for="(item, idx) of list" :key="idx">
        <span>{{ $srv.getI18nBySrv(item['title']) }}</span>
      </Radio>
    </RadioGroup>
  </div>
</template>

<script lang="ts">
import { ifs, T_srv, Tsrv, vue } from '@/services';

@T_srv.comp
export default class oPrintPanel extends vue {
  @T_srv.prop({
    required: true,
    type: String,
    default: '-1'
  })
  funID!: string;

  /* 父组件compBoxInfo */
  @T_srv.prop({
    required: false,
    type: Object,
    default: null
  })
  compBoxInfo: ifs.I_compBoxInfo;

  /* 组件名 */
  private G_compName: string = 'oPrintPanel';

  /* 组件箱信息对象 */
  private GT_compBoxInfo: ifs.I_compBoxInfo;

  /* 组件箱对象 */
  private GT_compBox: ifs.I_compBox;

  /* 组件箱识别ID */
  private G_compID: string;

  private list: Array<any> = [];

  public reportCode: string = '';

  private selectedTempIdx: number = -1;

  created() {
    // 如果父组件没有传参，那就产生一个
    this.GT_compBoxInfo = Tsrv.getCompInfo(this.compBoxInfo);
    this.G_compID = this.GT_compBoxInfo.compID;
    this.GT_compBox = this.GT_compBoxInfo.TcompBox;
    this.$emit('compBoxInfo', this.GT_compBoxInfo);
  }

  destroyed() {
    this.GT_compBox.removeCompMergeName(this.G_compID, this.G_compName);
  }

  mounted() {
    const filter: object = { _sys_fun_id: { $eq: this.funID } };
    Tsrv.getDataWithOption(
      this.$i18n.locale || 'en_US',
      'mysql',
      '_sys_printset',
      [],
      filter,
      '_sys_printset'
    ).then(([ok, res, _, err]) => {
      if (ok) {
        if (res.data.total > 0) {
          this.list = res.data.rows.filter(
            item => !Tsrv.utils.noValue(item['f_code'])
          );
        }
      } else {
        this.$msg(err);
      }
    });
    this.GT_compBox.addCompMergeName(this.G_compID, this.G_compName, this);
  }

  onChange(idx: number) {
    this.$emit('on-change', this.list[idx]);
  }
}
</script>

<style lang="scss" scoped>
.print-panel {
  display: flex;
  flex-direction: column;
  height: 100%;
  max-height: 100%;
  width: 90%;
  padding: 10px;
  margin-left: 15px;
  margin-top: 5px;
  border: 1px solid #eee;

  .print-radio {
    margin-left: 35px;
    margin-bottom: 8px;
  }
}
</style>
